#!/bin/ash
getconfig() {
	grep "key$1" /etc/plugin_config |awk -F '=' '{print $2}'|awk '{print substr($1,2)}'|awk '{print substr($1,1,length($1)-2)}'
}
resetconfig(){
port=$1
cat << EOF > /filebrowser.json
{
  "port": $port,
  "root":"/userdata",
  "noAuth": false,
  "baseURL": "",
  "address": "0.0.0.0",
  "reCaptchaKey": "",
  "reCaptchaSecret": "",
  "database":"/filebrowser.db",
  "log": "stdout",
  "plugin": "",
  "scope":"/userdata",
  "allowCommands": true,
  "allowEdit": true,
  "allowNew": true,
  "commands": [
    "ash",
    "awk",
    "busybox",
    "cat",
    "chmod",
    "chown",
    "grep",
    "kill",
    "killall",
    "ls",
    "lua",
    "mkdir",
    "mount",
    "ping",
    "plugin_action",
    "plugin_download",
    "ps",
    "rm",
    "sed",
    "sh",
    "sleep",
    "taskmonitorDaemon",
    "top",
    "git",
    "svn",
    "ls",
    "cd"
  ]
}
EOF
}

port=$(getconfig port)
resetconfig $port